<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // Function.prototype.myCall = function(context,...ars){
    //     context = context || window;
    //     console.log(context);
    //     const uid = Symbol('uid');
    //     context[uid] = this;
    //     console.log(context);
    //     const res = context[uid](...ars);
    //     delete context[uid];
    //     return res;
    // }

    // function greet(message){
    //     console.log(`${message},${this.name}`);
    // }
    // const person = {name:'zhangsan'};
    // greet.myCall(person,'hello');

    Function.prototype.myApply = function(context,ars){
        context = context || window;
        console.log(context);
        const uid = Symbol('uid');
        context[uid] = this;
        console.log(context);
        const res = context[uid](...ars);
        delete context[uid];
        return res;
    }

    function greet(message){
        console.log(`${message},${this.name}`);
    }
    const person = {name:'zhangsan'};
    greet.myApply(person,['hello']);
</script>

</html>